const db = uniCloud.database();
module.exports = async function(options = {}) {
	const { characterId, groupCode, params } = options;
	const token = this.getUniIdToken();
	if (!characterId || !token) {
		throw new Error('非法访问');
	}
	const [groupRes] = await Promise.all([
		db.collection('a-dz-group-list').where({ groupCode }).get({ getOne: true }),
	])
	if (groupRes.data.length && groupRes.data[0].characterId == characterId) { //保证创建角色才能修改
		await Promise.all([
			db.collection('a-dz-group-list').where({ groupCode }).update({
				...params
			})
		])
		return {
			code: 0,
			msg: '修改成功'
		}
	} else {
		throw new Error('非法访问');
	}
}